<template>
  <el-dialog v-model="dialogVisible" class="!border-rd-10px" title="修改征订时间" width="35%">
    <el-form
      ref="ruleFormRef"
      :model="ruleForm"
      label-width="auto"
      :size="formSize"
      status-icon
    >
      <el-form-item label="征订起止时间">
        <el-date-picker
          v-model="ruleForm.date1"
          type="datetimerange"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
          format="YYYY-MM-DD HH:mm:ss"
          date-format="YYYY-MM-DD dd"
          time-format="HH:mm:ss"
        />
        <div class="color-#a9a9a9 font-size-12px">注：设置征订开始时间和结束时间，时间到了后，将自动开启征订和结束征订。</div>
      </el-form-item>
      <el-form-item label="修改信息起止时间">
        <el-date-picker
          v-model="ruleForm.date2"
          type="datetimerange"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
          format="YYYY-MM-DD HH:mm:ss"
          date-format="YYYY-MM-DD dd"
          time-format="HH:mm:ss"
        />
        <div class="color-#a9a9a9 font-size-12px">设置修改商品信息开始时间和结束时间，家长只能在设置的时间范围内修改商品信息。</div>
      </el-form-item>
      <el-form-item label="修改商品信息起止时间">
        <el-date-picker
          v-model="ruleForm.date3"
          type="datetimerange"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
          format="YYYY-MM-DD HH:mm:ss"
          date-format="YYYY-MM-DD dd"
          time-format="HH:mm:ss"
        />
        <div class="color-#a9a9a9 font-size-12px">设置售后开始时间和结束时间，家长只能在设置的时间范围内申请售后</div>
      </el-form-item>
      <el-form-item label="售后起止时间">
        <el-date-picker
          v-model="ruleForm.date4"
          type="datetimerange"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
          format="YYYY-MM-DD HH:mm:ss"
          date-format="YYYY-MM-DD dd"
          time-format="HH:mm:ss"
        />
        <div class="color-#a9a9a9 font-size-12px">注：设置修改信息开始时间和结束时间，家长只能在设置的时间范围内修改信息。</div>
      </el-form-item>
    </el-form>
    <template #footer>
      <div class="text-center">
        <el-button type="primary" @click="submitForm(ruleFormRef)">确定</el-button>
      </div>
    </template>
  </el-dialog>
</template>
<script setup lang="ts">
import { reactive, ref } from 'vue'
import type { ComponentSize, FormInstance, FormRules } from 'element-plus'

interface RuleForm {
  date1: string[],
  date2: string[],
  date3: string[],
  date4: string[]
}

const formSize = ref<ComponentSize>('default')
const ruleFormRef = ref<FormInstance>()
const ruleForm = reactive<RuleForm>({
  date1: [],
  date2: [],
  date3: [],
  date4: []
})


const submitForm = async (formEl: FormInstance | undefined) => {
  if (!formEl) return
  await formEl.validate((valid, fields) => {
    if (valid) {
      // console.log('submit!')
    } else {
      // console.log('error submit!', fields)
    }
  })
}

const dialogVisible = ref(false)
function show(val) {
  dialogVisible.value = val
}
defineExpose({ show, dialogVisible })
</script>
<style scoped lang="scss"></style>
